package com.haixiaoke.saas.user.service.impl;

import com.haixiaoke.saas.user.domain.UserRole;
import com.haixiaoke.saas.user.mapper.UserRoleMapper;
import com.haixiaoke.saas.user.service.IUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 企业端用户和角色关联Service业务层处理
 *
 * @author panda
 * @date 2023-12-29
 */
@Service
public class UserRoleServiceImpl implements IUserRoleService {
    @Autowired
    private UserRoleMapper userRoleMapper;

    /**
     * 查询企业端用户和角色关联
     *
     * @param userId 企业端用户和角色关联主键
     * @return 企业端用户和角色关联
     */
    @Override
    public UserRole selectBizUserRoleByUserId(Long userId) {
        return userRoleMapper.selectBizUserRoleByUserId(userId);
    }

    /**
     * 查询企业端用户和角色关联列表
     *
     * @param userRole 企业端用户和角色关联
     * @return 企业端用户和角色关联
     */
    @Override
    public List<UserRole> selectBizUserRoleList(UserRole userRole) {
        return userRoleMapper.selectBizUserRoleList(userRole);
    }

    /**
     * 新增企业端用户和角色关联
     *
     * @param userRole 企业端用户和角色关联
     * @return 结果
     */
    @Override
    public int insertBizUserRole(UserRole userRole) {
        return userRoleMapper.insertBizUserRole(userRole);
    }

    /**
     * 修改企业端用户和角色关联
     *
     * @param userRole 企业端用户和角色关联
     * @return 结果
     */
    @Override
    public int updateBizUserRole(UserRole userRole) {
        return userRoleMapper.updateBizUserRole(userRole);
    }

    /**
     * 批量删除企业端用户和角色关联
     *
     * @param userIds 需要删除的企业端用户和角色关联主键
     * @return 结果
     */
    @Override
    public int deleteBizUserRoleByUserIds(Long[] userIds) {
        return userRoleMapper.deleteBizUserRoleByUserIds(userIds);
    }

    /**
     * 删除企业端用户和角色关联信息
     *
     * @param userId 企业端用户和角色关联主键
     * @return 结果
     */
    @Override
    public int deleteBizUserRoleByUserId(Long userId) {
        return userRoleMapper.deleteBizUserRoleByUserId(userId);
    }

    @Override
    public int countUserRoleByRoleId(Long roleId) {
        return userRoleMapper.countUserRoleByRoleId(roleId);
    }

    @Override
    public int deleteUserRoleInfo(UserRole userRole) {
        return userRoleMapper.deleteUserRoleInfo(userRole);
    }

    @Override
    public int deleteUserRoleInfos(Long roleId, Long[] userIds) {
        return userRoleMapper.deleteUserRoleInfos(roleId, userIds);
    }

    @Override
    public int batchUserRole(List<UserRole> list) {
        return userRoleMapper.batchUserRole(list);
    }

    @Override
    public int deleteBizUserRoleByUserIdAndTenantId(Long userId, String tenantId) {
        return userRoleMapper.deleteBizUserRoleByUserIdAndTenantId(userId, tenantId);
    }

    @Override
    public int deleteBizUserRoleByRoleId(Long roleId) {
        return userRoleMapper.deleteBizUserRoleByRoleId(roleId);
    }
}
